package com.ruoyi.schoolSys.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.schoolSys.domain.StudentAttendance;
import com.ruoyi.schoolSys.service.IStudentAttendanceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 学生签到管理Controller
 * 
 * @author ruoyi
 * @date 2024-02-21
 */
@RestController
@RequestMapping("/schoolSys/studentAttendance")
public class StudentAttendanceController extends BaseController
{
    @Autowired
    private IStudentAttendanceService studentAttendanceService;

    /**
     * 查询学生签到管理列表
     */
    @PreAuthorize("@ss.hasPermi('schoolSys:studentAttendance:list')")
    @GetMapping("/list")
    public TableDataInfo list(StudentAttendance studentAttendance)
    {
        startPage();
        List<StudentAttendance> list = studentAttendanceService.selectStudentAttendanceList(studentAttendance);
        return getDataTable(list);
    }

    /**
     * 导出学生签到管理列表
     */
    @PreAuthorize("@ss.hasPermi('schoolSys:studentAttendance:export')")
    @Log(title = "学生签到管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, StudentAttendance studentAttendance)
    {
        List<StudentAttendance> list = studentAttendanceService.selectStudentAttendanceList(studentAttendance);
        ExcelUtil<StudentAttendance> util = new ExcelUtil<StudentAttendance>(StudentAttendance.class);
        util.exportExcel(response, list, "学生签到管理数据");
    }

    /**
     * 获取学生签到管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('schoolSys:studentAttendance:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(studentAttendanceService.selectStudentAttendanceById(id));
    }

    /**
     * 新增学生签到管理
     */
    @PreAuthorize("@ss.hasPermi('schoolSys:studentAttendance:add')")
    @Log(title = "学生签到管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody StudentAttendance studentAttendance)
    {
        return toAjax(studentAttendanceService.insertStudentAttendance(studentAttendance));
    }

    /**
     * 修改学生签到管理
     */
    @PreAuthorize("@ss.hasPermi('schoolSys:studentAttendance:edit')")
    @Log(title = "学生签到管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody StudentAttendance studentAttendance)
    {
        return toAjax(studentAttendanceService.updateStudentAttendance(studentAttendance));
    }

    /**
     * 删除学生签到管理
     */
    @PreAuthorize("@ss.hasPermi('schoolSys:studentAttendance:remove')")
    @Log(title = "学生签到管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(studentAttendanceService.deleteStudentAttendanceByIds(ids));
    }
}
